﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace P2PLib.Common.DataModel
{
    /// <summary>
    /// This class contains the information of a client
    /// </summary>
    public class ClientInfo
    {
        private IPAddress ip;
        private int port;

        public ClientInfo(string ip, int port)
        {
            this.ip = IPAddress.Parse(ip);
            this.port = port;
        }

        public IPAddress IP
        {
            get { return ip; }
            set { ip = value; }
        }
        public int Port
        {
            get { return port; }
            set { port = value; }
        }

        /// <summary>
        /// 判断两个ClientInfo相等的方法
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            return this.ip.ToString().Equals(((ClientInfo)obj).IP.ToString());
        }
    }
}
